<template>
  <dt-modal-edit ref='modal' title='奖金单提交' :label-width='220' :width='700' @ok='onOk'>
  </dt-modal-edit>
</template>

<script>
  import Opt from '../opt/SubmitOpt.js'
  import billMgr from '@/biz/bonus/bill'
  import specialMgr from '@/biz/bonus/billSpecial'
  
  export default {
    data() {
      return {
        old: {
          specialGrantType: '',
          preRatio: null,
          settlementRatio: null,
          yearEndRatio: null,
          handoverRatio: null,
          oaCode: '',
        },
        info: {}
      }
    },
    mounted() {
    },
    methods: {
      show(info) {
        console.log(info)
        this.info = { ...info, ...this.old }
        this.$refs.modal.show(new Opt(this.info))
      },
      hide() {
        this.$refs.modal.hide()
      },
      onOk() {
        if (this.info.bonusType == 'SPECIAL') {
          specialMgr.submit(this.info).then(res => {
            this.$router.go(-1)
            this.hide()
          })
        } else {
          billMgr.submit(this.info).then(res => {
            this.$router.go(-1)
            this.hide()
          })
        }
      }
    }
  }
</script>

<style>
</style>
